home *** CD-ROM | disk | FTP | other *** search
- Path: erich.triumf.ca!bennett
- From: bennett@erich.triumf.ca (P.Bennett)
- Newsgroups: comp.lang.c
- Subject: Re: Newbie needs help w/ARGV ARGC
- Date: 24 Mar 1996 22:00 PST
- Organization: TRIUMF: Tri-University Meson Facility
- Distribution: world
- Message-ID: <24MAR199622002745@erich.triumf.ca>
- References: <4j4ja1$dc3@mtinsc01-mgt.ops.worldnet.att.net>
- NNTP-Posting-Host: ftp.triumf.ca
- News-Software: VAX/VMS VNEWS 1.50
-
- In article <4j4ja1$dc3@mtinsc01-mgt.ops.worldnet.att.net>, dslayer@worldnet.att.net (Raymond Joh) writes...
- >I have spent three days attempting to determine why my command line
- >arguments are failing...
- >
- >I am using MS Quick C 2.5
- >
- >I just want to be able to enter two file paths at the command line.
- >Here is my code:
- >
- >#include <stdio.h>
- >#include <stdlib.h>
-
- >main(int argc, char *argv[],char *envp[])
- >{
- >FILE *ofp,*nfp;
- >char ch;
- >
- >gets(*argv);
-
- Why?? This will require the user to enter something, and (I think) over-write
- the command-line arguments. In any case, _never_ use gets() - always use
- fgets() instead.
-
- >
- >if (argc!=3)
- > {
- > printf("Enter: <source> <destination>\n");
- > exit(1);
- > }
- >
- >Code countinues but when I enter my command line input such as:
- >
- >A:\readme.txt A:\newfile.txt
- >
- >I get my arvc error message above
- >I'm sure I've missed something simple but it has me stumped.
- >(win95 if OS matters.)
-
-
- I think you are confused about what "command line arguments" are. Command line
- arguments are things given following the program name, for example, to start
- your program with command line arguments you would say:
- "myprog A:\readme.txt A:\newfile.txt"
- all on one line.
-
- Then argc ==3 and argv[0] is "myprog", argv[1] is "a:\reame.txt", and argv[2]
- is "newfile.txt"
-
- Now, can you do this in Win95?? Or will your program have to put up a window
- and ask for file names??
-
- Peter Bennett VE7CEI | Vessels shall be deemed to be in sight
- Internet: bennett@triumf.ca | of one another only when one can be
- Packet: ve7cei@ve7kit.#vanc.bc.ca | observed visually from the other
- TRIUMF, Vancouver, B.C., Canada | ColRegs 3(k)
- GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
- or: ftp://ftp-i2.informatik.rwth-aachen.de/pub/arnd/GPS/peter/index.html
-
-